/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package lineage.controller.pc;

import lineage.model.instance.L1PcInstance;

/**
 * 角色初始相关.
 * 
 * @version 2014年3月21日下午9:26:40
 * @author jrwz
 */
public final class Original {
    private Original() {
    }

    /** 各职业初始属性数组：力量值 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_STR = new int[] { 13, 16, 11, 8, 12, 13, 11 };
    /** 各职业初始属性数组：敏捷值 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_DEX = new int[] { 10, 12, 12, 7, 15, 11, 10 };
    /** 各职业初始属性数组：体质值 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_CON = new int[] { 10, 14, 12, 12, 8, 14, 12 };
    /** 各职业初始属性数组：精神值 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_WIS = new int[] { 11, 9, 12, 12, 10, 12, 12 };
    /** 各职业初始属性数组：智力值 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_INT = new int[] { 10, 8, 12, 12, 11, 11, 12 };
    /** 各职业初始属性数组：魅力值 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_CHA = new int[] { 13, 12, 9, 8, 9, 8, 8 };

    /** 各职业初始可分配点数 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_COUNT = new int[] { 8, 4, 7, 16, 10, 6, 10 };

    /** 各职业外形编号 (王、骑、妖、法、黑、龙、幻) [性别、职业]. */
    private static final int[][] CLASS_ID = new int[][] { //
    new int[] { 0, 61, 138, 734, 2786, 6658, 6671 }, // 男
            new int[] { 1, 48, 37, 1186, 2796, 6661, 6650 } // 女
    };

    /** 各职业出生坐标 (王、骑、妖、法、黑、龙、幻) [职业、X、Y、地图编号]. */
    private static final int[][] LOCATION = new int[][] { //
    new int[] { 32684, 32870, 2005 }, //
            new int[] { 32686, 32867, 2005 }, //
            new int[] { 32691, 32864, 2005 }, //
            new int[] { 32684, 32870, 2005 }, //
            new int[] { 32686, 32867, 2005 }, //
            new int[] { 32691, 32864, 2005 }, //
            new int[] { 32691, 32864, 2005 } //
    };

    /** 各职业的初始血量 (王、骑、妖、法、黑、龙、幻) [职业]. */
    private static final int[] ORIGINAL_HP = new int[] { 14, 16, 15, 12, 12, 15, 15 };

    /**
     * 取得与该角色职业对应的初始属性：力量值.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始属性：力量值
     */
    protected static final int getOriginalStr(final L1PcInstance pc) {
        return ORIGINAL_STR[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的初始属性：敏捷值.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始属性：敏捷值
     */
    protected static final int getOriginalDex(final L1PcInstance pc) {
        return ORIGINAL_DEX[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的初始属性：体质值.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始属性：体质值
     */
    protected static final int getOriginalCon(final L1PcInstance pc) {
        return ORIGINAL_CON[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的初始属性：精神值.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始属性：精神值
     */
    protected static final int getOriginalWis(final L1PcInstance pc) {
        return ORIGINAL_WIS[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的初始属性：智力值.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始属性：智力值
     */
    protected static final int getOriginalInt(final L1PcInstance pc) {
        return ORIGINAL_INT[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的初始属性：魅力值.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始属性：魅力值
     */
    protected static final int getOriginalCha(final L1PcInstance pc) {
        return ORIGINAL_CHA[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的初始可分配点数.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的可分配点数
     */
    protected static final int getOriginalCount(final L1PcInstance pc) {
        return ORIGINAL_COUNT[pc.getType()];
    }

    /**
     * 取得与该角色职业对应的外形编号.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的外形编号
     */
    protected static final int getClassId(final L1PcInstance pc) {
        return CLASS_ID[pc.getSex()][pc.getType()];
    }

    /**
     * 取得与该角色职业对应的出生坐标.
     * 
     * @param pc
     *            - 角色
     * @return 数组[0：x坐标、1：y坐标、2：地图编号]
     */
    protected static final int[] getLocation(final L1PcInstance pc) {
        return LOCATION[pc.getType()];
    }

    /**
     * 取得各职业的初始血量.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始血量值
     */
    protected static final int getOriginalHp(final L1PcInstance pc) {
        return ORIGINAL_HP[pc.getSpareType()];
    }

    /**
     * 取得各职业的初始魔量.
     * 
     * @param pc
     *            - 角色
     * @return 与该职业对应的初始魔量值
     */
    protected static final int getOriginalMp(final L1PcInstance pc) {
        int mp = 1;
        if (pc.isCrown()) {
            switch (pc.getWis()) {
            case 11:
                mp = 2;
                break;
            case 12:
            case 13:
            case 14:
            case 15:
                mp = 3;
                break;
            case 16:
            case 17:
            case 18:
                mp = 4;
                break;
            default:
                mp = 2;
                break;
            }
        } else if (pc.isKnight()) {
            switch (pc.getWis()) {
            case 9:
            case 10:
            case 11:
                mp = 1;
                break;
            case 12:
            case 13:
                mp = 2;
                break;
            default:
                mp = 1;
                break;
            }
        } else if (pc.isElf()) {
            switch (pc.getWis()) {
            case 12:
            case 13:
            case 14:
            case 15:
                mp = 4;
                break;
            case 16:
            case 17:
            case 18:
                mp = 6;
                break;
            default:
                mp = 4;
                break;
            }
        } else if (pc.isWizard()) {
            switch (pc.getWis()) {
            case 12:
            case 13:
            case 14:
            case 15:
                mp = 6;
                break;
            case 16:
            case 17:
            case 18:
                mp = 8;
                break;
            default:
                mp = 6;
                break;
            }
        } else if (pc.isDarkElf()) {
            switch (pc.getWis()) {
            case 10:
            case 11:
                mp = 3;
                break;
            case 12:
            case 13:
            case 14:
            case 15:
                mp = 4;
                break;
            case 16:
            case 17:
            case 18:
                mp = 6;
                break;
            default:
                mp = 3;
                break;
            }
        } else if (pc.isDragonKnight()) {
            switch (pc.getWis()) {
            case 12:
            case 13:
            case 14:
            case 15:
                mp = 4;
                break;
            case 16:
            case 17:
            case 18:
                mp = 6;
                break;
            default:
                mp = 4;
                break;
            }
        } else if (pc.isIllusionist()) {
            switch (pc.getWis()) {
            case 12:
            case 13:
            case 14:
            case 15:
                mp = 4;
                break;
            case 16:
            case 17:
            case 18:
                mp = 6;
                break;
            default:
                mp = 4;
                break;
            }
        }
        return mp;
    }

    /**
     * 取得各职业的初始物理防御值(敏捷加成).
     * 
     * @param pc
     *            - 角色
     * @return 与该职业的‘初始敏捷加点’对应的‘物理防御值’
     */
    protected static final int getOriginalAc(final L1PcInstance pc) {
        final int originalDex = pc.getOriginalDex();
        final int baseAc = 10;
        int originalAc = 0;
        if (pc.isCrown()) {
            if ((originalDex >= 12) && (originalDex <= 14)) {
                originalAc = 1;
            } else if ((originalDex == 15) || (originalDex == 16)) {
                originalAc = 2;
            } else if (originalDex >= 17) {
                originalAc = 3;
            }
        } else if (pc.isKnight()) {
            if ((originalDex == 13) || (originalDex == 14)) {
                originalAc = 1;
            } else if (originalDex >= 15) {
                originalAc = 3;
            }
        } else if (pc.isElf()) {
            if ((originalDex >= 15) && (originalDex <= 17)) {
                originalAc = 1;
            } else if (originalDex == 18) {
                originalAc = 2;
            }
        } else if (pc.isDarkElf()) {
            if (originalDex >= 17) {
                originalAc = 1;
            }
        } else if (pc.isWizard()) {
            if ((originalDex == 8) || (originalDex == 9)) {
                originalAc = 1;
            } else if (originalDex >= 10) {
                originalAc = 2;
            }
        } else if (pc.isDragonKnight()) {
            if ((originalDex == 12) || (originalDex == 13)) {
                originalAc = 1;
            } else if (originalDex >= 14) {
                originalAc = 2;
            }
        } else if (pc.isIllusionist()) {
            if ((originalDex == 11) || (originalDex == 12)) {
                originalAc = 1;
            } else if (originalDex >= 13) {
                originalAc = 2;
            }
        }

        originalAc = baseAc - originalAc;
        return originalAc;
    }
}
